import request from '@/utils/request';

/**
 * 分页查询用户
 */
export async function get_list(params) {
  const res = await request.post('/purchase/receipts_supplement/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}

/* 单据详情 */
export async function receipts_purchase_detail(params) {
  const res = await request.post('/purchase/receipts_supplement/detail', params);
  if (res.data.code === 1) {
    return res.data.data;
  }
  return Promise.reject(res.data.msg);
}

/* 作废 */
export async function cancel_purchase(params) {
  const res = await request.post(
    '/purchase/receipts_supplement/cancel_supplement',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 删除 */
export async function del_receipts(params) {
  const res = await request.post(
    '/purchase/receipts_supplement/del_receipts',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 反审 */
export async function back_verify(params) {
  const res = await request.post(
    '/purchase/receipts_supplement/back_verify',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 取消审核 */
export async function cancel_verify(params) {
  const res = await request.post(
    '/purchase/receipts_supplement/cancel_verify',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 提交审核 */
export async function confirm_purchase(params) {
  const res = await request.post(
    '/purchase/receipts_supplement/confirm_supplement',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}

/* 添加货品 */
export async function add_goods(params) {
  const res = await request.post('/purchase/receipts_supplement/add_goods', params);
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}

/* 删除货品 */
export async function del_goods(params) {
  const res = await request.post('/purchase/receipts_supplement/del_goods', params);
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 新增原因 */
export async function addreasons(params) {
  const res = await request.post('/purchase/receipts_cause/add', params);
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 编辑原因 */
export async function editreasons(params) {
  const res = await request.post('/purchase/receipts_cause/edit', params);
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 删除原因 */
export async function deletereasons(params) {
  const res = await request.post('/purchase/receipts_cause/delete', params);
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 排序原因 */
export async function editsortreasons(params) {
  const res = await request.post('/purchase/receipts_cause/edit_sort', params);
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 原因列表 */
export async function get_reason_list(params) {
  const res = await request.post('/purchase/receipts_cause/get_list', params);
  if (res.data.code === 1) {
    return res.data.data;
  }
  return Promise.reject(res.data.msg);
}
/* 批量录入 */
export async function batch_enter(params) {
  const res = await request.post(
    '/purchase/receipts_supplement/batch_enter',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
